<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/25
 * Time: 12:04
 */
$table = new swoole_table(1024);
//创建内存表
$table->column('id', $table::TYPE_INT, 4);
$table->column('name', $table::TYPE_STRING, 32);
$table->column('age', $table::TYPE_INT, 2);
$table->create();
//添加值
$table->set('ht', ['id'=>1 , 'name'=> 'ht', 'age'=> 330]);
$table->set('singwa', ['id'=>33 , 'name'=> 'singwa', 'age'=> 88]);
$table->set('junshi', ['id'=>10000 , 'name'=> 'junshi', 'age'=> 999]);
//另外一种存值方式，会多出key，value下标
$table['gxf'] = ['id'=>999 , 'name'=> 'gxf', 'age'=> 99];

//原子增加，减少操作
$table->incr('ht', 'age', 5);
$table->decr('singwa', 'id', 3);
//删除
$table->del('junshi');
//是否存在
var_dump($table->exist('junshi'));

print_r($table->get('ht'));
print_r($table->get('singwa'));
print_r($table->get('junshi'));
print_r($table['gxf']);